<!--
 * @Author: zhangxiangsheng 1026583651@qq.com
 * @Date: 2024-06-24 14:42:24
 * @LastEditors: zhangxiangsheng 1026583651@qq.com
 * @LastEditTime: 2024-06-24 16:41:54
 * @FilePath: \appGly\pages\USearch\uedt.vue
 * @Description: 
 * 
 * Copyright (c) 2024 by ${git_name_email}, All Rights Reserved. 
-->
<template>
  <view>
    <u-navbar title="用户查看"></u-navbar>
    <formz ref="formz" :inputs="inputs" :data="data"></formz>
    <fixedbtn>
      <u-button type="error" @click="del" :loading="loading">
        {{ $z.$t("删除账户") }}
      </u-button>
      <view style="width: 40rpx"></view>
      <u-button
        type="primary"
        @click="$z.gopage(`/pages/USearch/udmaedt?uUser=${query.uUser}`)"
        :loading="loading"
      >
        {{ $z.$t("修改密码") }}
      </u-button>
      <view style="width: 40rpx"></view>
      <u-button type="primary" @click="save" :loading="loading">
        {{ $z.$t("确认修改") }}
      </u-button>
    </fixedbtn>
    <zmodal ref="zmodal"></zmodal>
  </view>
</template>

<script>
  import json from "./json";
  export default {
    data() {
      return {
        inputs: json.Uedtjson,
        loading: false,
        data: {},
        query: {},
      };
    },
    onLoad(query) {
      this.query = query;
      this.init();
    },
    methods: {
      async init() {
        let user = await this.$z.request("/USearch", this.query);
        this.data = user[0];
      },
      del() {
        this.$refs.zmodal.init({
          showcancel: true,
          content: "删除此账户？",
          confirm: async () => {
            await this.$z.request("/Udel", this.query);
            this.$z.back();
          },
        });
      },
      async save() {
        let data = await this.$refs.formz.validate();
        this.loading = true;
        let par = await this.$z.request("/Uedt", data);
        if (par[0].par == "succeed") {
          this.$z.back();
        } else {
          this.$u.toast("操作失败");
        }
        this.loading = false;
      },
    },
  };
</script>

<style></style>
